package gcontactsservice.gcontactstomobileservletsupport;

import gcontactsservice.GContactsService;

import java.io.*;
import javax.servlet.http.HttpSession;

public class EndToEndGateways {
    
    /**
     *  This class implements the application server connectivity specific to the needs.
     */
    public static class gcontactsservice_GContactsServiceTestoperation1Gateway implements InvocationAbstraction {
        /**
         *  This method performs the actual invocation of server functionality. It is
         *  used by the servlet to delegate functionality to external classes.
         *
         *@param  clientID         The unique identifier of a client
         *@param  input            The stream from which we should read the parameters
         *      for the methods
         *@return                  The return value for the method NULL IS NOT
         *      SUPPORTED!!!!
         *@exception  IOException  Thrown when a protocol error occurs
         */
        public Object invoke(HttpSession session, DataInput input) throws Exception {
            String[] param1;
            short type1 = input.readShort(); // reading the type
                if (type1 == -1) { // NULL_TYPE) {
                    param1 = null;
            } else {
                Object o = Utility.readArray(input);
                if (o instanceof String[]) {
                    param1 = (String[]) o;
                } else {
                    Object[] objArray = (Object[]) o;
                    param1 = new String[objArray.length];
                    for (int i = 0; i < objArray.length; i++) {
                        param1[i] = (String) objArray[i];
                    }
                }
            }
            gcontactsservice.GContactsService instance = (gcontactsservice.GContactsService)
                session.getAttribute("gcontactsservice.GContactsService");
            if (instance == null) {
                instance = (gcontactsservice.GContactsService) Class.forName("gcontactsservice.GContactsService").newInstance();
                session.setAttribute("gcontactsservice.GContactsService", instance);
            }
            return Utility.toObject(instance.testoperation(param1));
            
        }
    }
    
    private static Object readObject(DataInput in) throws IOException {
        return Utility.readObject(in);
    }
}
